package com.licq.ldoc.parser.impl.annotation;

import java.lang.annotation.Annotation;

import net.sf.oval.constraint.NotMemberOf;

import org.apache.commons.lang.StringUtils;

import com.licq.ldoc.domain.Attribute;
import com.licq.ldoc.domain.AttributeType;
import com.licq.ldoc.parser.AnnotationParsee;

public class NotMemberOfAnnotationParsee extends AnnotationParsee {

	public NotMemberOfAnnotationParsee(AnnotationParsee successor) {
		super(successor);
	}

	@Override
	protected void doParse(Attribute attribute, Annotation annotation) {
		AttributeType type = attribute.getType();
		if (AttributeType.ENUM == type || AttributeType.STRING == type) {
			NotMemberOf notMemberOf = (NotMemberOf) annotation;
			attribute.appendComments(String.format(getText(), StringUtils.join(notMemberOf.value(), ", "),
					notMemberOf.ignoreCase() ? "(ignore case)" : ""));
		}
	}
	
}
